import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class CustomCategory extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      alignment: Alignment.center,
      margin: EdgeInsets.only(top: 5),
      height: 150,
      child: GridView.count(
        physics: NeverScrollableScrollPhysics(),
        primary: false,
        mainAxisSpacing: 5.0,              // 竖向间距
        crossAxisCount: 5,                  // 横向 Item 的个数
        children: buildGridTileList(10),
      ),
    );
  }

  List<String> title = [
    "金币",
    "蚂蚁庄园",
    "充值中心",
    "花呗",
    "借呗",
    "饿了么",
    "美团",
    "京东",
    "付款",
    "出行"
  ];
  List<Icon> icon = [
    Icon(Icons.monetization_on,color: Colors.amber,size: 40,),
    Icon(Icons.face,color: Colors.deepOrangeAccent,size: 40,),
    Icon(Icons.ac_unit,color: Colors.greenAccent,size: 40,),
    Icon(Icons.favorite,color: Colors.red,size: 40,),
    Icon(Icons.settings,color: Colors.black,size: 40,),
    Icon(Icons.account_circle,color: Colors.blueAccent,size: 40,),
    Icon(Icons.backup,color: Colors.lightGreen,size: 40,),
    Icon(Icons.business_center,color: Colors.purple,size: 40,),
    Icon(Icons.child_friendly,color: Colors.green,size: 40,),
    Icon(Icons.local_movies,color: Colors.black38,size: 40,),
  ];

  List<Widget> buildGridTileList(int number) {
    List<Widget> widgetList = new List();
    for (int i = 0; i < number; i++) {
      widgetList.add(
        InkWell(
            splashColor: Colors.transparent,
            highlightColor: Colors.transparent,
            onTap: (){
              print('index');
            },
            child: Column(
              mainAxisSize: MainAxisSize.min,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: <Widget>[
                icon[i],
                Text(title[i],style: TextStyle(
                    color: Colors.black87,
                    fontWeight: FontWeight.w400,
                    fontSize: 13
                ),)
              ],
            ),
          ),
      );
    }
    return widgetList;
  }
}
